Skip to content

fix(dag+hlo): conv1d/gather/pooling/flatten + IREE-valid reduce_window — 7/7 models compile (#675)#676

Merged
michalharakal merged 1 commit into
developfrom
fix/conv-gather-pool-reducewindow-675
Jun 6, 2026
Merged

fix(dag+hlo): conv1d/gather/pooling/flatten + IREE-valid reduce_window — 7/7 models compile (#675)#676
michalharakal merged 1 commit into
developfrom
fix/conv-gather-pool-reducewindow-675

Conversation

@michalharakal

Copy link
Copy Markdown
Contributor

Closes #675. Follow-up to #674 — completes the DAG-DSL StableHLO export so every conformance model and op compiles with iree-compile.

Fixes

inferDagOutputSpecs (skainet-lang-dag) — add output-shape rules for the ops that still echoed operand-0:

  • conv1d(N,Cin,L) * (Cout,_,K) → (N, Cout, floor((L+2p − d(K−1) − 1)/s) + 1). conv2d already inferred via Conv2dOperation; conv1d was a GenericOperation.
  • gathertable[:axis] ⊕ indices.shape ⊕ table[axis+1:].
  • maxpool2d/avgpool2d — windowed (N, C, Hout, Wout).
  • flatten — collapse [startDim..endDim], preserving the leading batch dim (it was collapsing everything to rank-1, which broke the dense matmul in mnist-cnn).

reduce_window emission (NeuralNetOperationsConverter) — emit IREE's parseable generic region form instead of the pretty applies … over window form IREE rejects (has no custom assembly form). Full NCHW-rank window attributes; region-local SSA names made unique per op (two pools in one function); avg-pool divisor splatted to the output type (was a scalar-vs-tensor mismatch).

MlirValidator — register region block-argument SSA defs (^bb0(%a, %b)) and every %x = result on a line, so single-line region ops validate.

Verification (mavenLocal, no release risk)

Published an unsigned 0.28.1-SNAPSHOT to ~/.m2 and ran skainet-iree-conformance against it:

before (#674) this PR
ops compile 23/27 27/27
models compile 6/7 7/7 (incl. mnist-cnn)

DagConvGatherPoolExportTest 5/5 green; skainet-compile-hlo / skainet-compile-dag / skainet-lang-dag jvmTest suites green.

After this merges

The export → iree-compile path is fully green for the conformance suite. Recommend cutting 0.28.1 (verify once more via mavenLocal), then the SKaiNET-transformers release decision reopens.

…reduce_window (#675)

Follow-up to #674. Completes DAG-DSL StableHLO export so every conformance model
and op compiles with iree-compile.

inferDagOutputSpecs (skainet-lang-dag) gains shape rules for:
- conv1d  : (N,Cin,L) * (Cout,_,K) -> (N, Cout, floor((L+2p - d(K-1) - 1)/s) + 1)
- gather  : table[:axis] + indices.shape + table[axis+1:]
- maxpool/avgpool : windowed (N, C, Hout, Wout)
- flatten : collapse dims [startDim..endDim], preserving the leading batch dim
            (it was collapsing everything to rank-1, breaking the dense matmul in mnist-cnn)
conv2d already inferred via Conv2dOperation; conv1d was a GenericOperation that fell
back to echoing operand-0.

reduce_window emission (NeuralNetOperationsConverter): emit the IREE-parseable generic
region form  %r = "stablehlo.reduce_window"(%in, %init) ({ ^bb0(%a, %b): ... })  instead
of the pretty  "applies <op> over window dimensions = ..."  form IREE rejects
("has no custom assembly form"). Full NCHW-rank window attributes; region-local SSA
names made unique per op so two pools in one function don't collide in the validator;
avg-pool divisor splatted to the output type (was a scalar-vs-tensor mismatch).

MlirValidator: register region block-argument SSA defs (^bb0(%a, %b)) and every
"%x =" result on a line, so single-line region ops validate.

Verified end-to-end via an unsigned 0.28.1-SNAPSHOT on mavenLocal + skainet-iree-conformance:
27/27 ops and 7/7 models (incl. mnist-cnn) iree-compile to a vmfb.
DagConvGatherPoolExportTest 5/5 green; hlo / dag / lang-dag suites green.
@michalharakal michalharakal merged commit 21f9a71 into develop Jun 6, 2026
6 checks passed
@michalharakal michalharakal deleted the fix/conv-gather-pool-reducewindow-675 branch June 6, 2026 16:05
@github-actions

github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown

📖 Documentation Preview

The documentation has been built successfully for this PR.

Generated Files:

  • Operator documentation: docs/modules/operators/_generated_/
  • JSON schema output: operators.json

Artifacts:

  • Download the documentation-preview-676 artifact to view the complete documentation locally.

This comment will be updated automatically when the PR is updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Post-#674: conv1d/gather/pooling output-spec + reduce_window emission still block iree-compile

1 participant